/**
 * sysLogServiceImpl
 * 项目名称:分秒金融
 *
 * @author lunli
 *
 * 功能描述:操作日志管理
 * 
 * 历史版本:2017-04-18 v1.0.0 lunli  创建:
 * 
 */
package com.fmjr.sys.sysLog.service.impl;

import com.fmjr.common.base.exception.BusinessException;
import com.fmjr.common.base.util.Pager;
import com.fmjr.common.util.SqlUtil;
import com.fmjr.sys.sysLog.bean.SysLog;
import com.fmjr.sys.sysLog.dao.SysLogDao;
import com.fmjr.sys.sysLog.service.ISysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service("sysLogService")
public class  SysLogServiceImpl implements ISysLogService {
	

	@Autowired
    private SysLogDao sysLogDao;

	/**
	 * 根据条件查询操作日志记录
	 * @author lunli
	 * @param  pager
	 * @return SysLogList
	 * @throws BusinessException
	 */
	public void selectSysLogList(Pager<SysLog> pager) throws BusinessException{
		int totalCount = sysLogDao.selectSysLogCount(pager);
		int numPerPage = SqlUtil.checkPageSize(pager.getNumPerPage());
		int currentPage = SqlUtil.checkPageCurrent(totalCount, numPerPage, pager.getPageNum());
		pager.setLimitStart(SqlUtil.countOffset(currentPage, numPerPage));
		pager.setPageSize(numPerPage);
		pager.setCurrentPage(currentPage);
		pager.setTotalCount(totalCount);
		pager.setTotalPage(totalCount%numPerPage==0?totalCount/numPerPage:totalCount/numPerPage+1);
		List<SysLog> list = sysLogDao.selectSysLogList(pager);
		pager.setList(list);
	}
	
	/**
	 * 根据ID查询操作日志记录
	 * @author lunli
	 * @param id
	 * @return domain
	 * @throws BusinessException
	 */
	public SysLog selectSysLogById(Long id) throws BusinessException{
		return sysLogDao.selectSysLogById(id);
	}

	/**
	 *  删除操作日志记录
	 * @author lunli	 
	 * @param id
	 * @throws BusinessException
	 */
	@Transactional(rollbackFor=BusinessException.class)
	public int deleteSysLogById(Long id) throws BusinessException{
		return sysLogDao.deleteSysLogById(id);
	}
	
	/**
	 * 修改操作日志记录
	 * @author lunli
	 * @param sysLog
	 * @throws BusinessException
	 */
	@Transactional(rollbackFor=BusinessException.class)
	public int updateSysLog(SysLog sysLog) throws BusinessException{
		return sysLogDao.updateSysLogSelective(sysLog);
	}

	/**
	 * 新增操作日志记录
	 * @author lunli
	 * @param sysLog
	 * @return
	 * @throws BusinessException
	 */
	@Transactional(rollbackFor=BusinessException.class)
	public int createSysLog(SysLog sysLog) throws BusinessException{
		return sysLogDao.createSysLog(sysLog);
	}
	

	

}
